package com.jingjin.humanityservice.controller;

import com.jingjin.common.result.BaseResult;
import com.jingjin.common.result.ResultUtil;
import com.jingjin.common.utils.UserContext;
import com.jingjin.humanityservice.service.DailySentenceService;
import com.jingjin.model.humanity.po.DailySentence;
import com.jingjin.model.humanity.vo.ChatSessionSimpleVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 每日句子控制器
 *
 * @author fxab
 * @date 2024/08/31
 */
@RefreshScope // 自动配置更新
@RestController
@RequestMapping("/sentence")
@Slf4j
@Tag(name = "每日一言接口文档", description = "每日一言模块接口文档")
public class DailySentenceController {

    /**
     * 每日句子服务
     */
    @Resource
    private DailySentenceService dailySentenceService;

    /**
     * 获取每日句子
     *
     * @return {@link BaseResult}<{@link String}>
     */
    @Operation(summary = "获取每日一言")
    @GetMapping("/get/random")
    @Transactional
    public BaseResult<String> getDailySentence(){
        DailySentence dailySentence = dailySentenceService.getRandom();
        return ResultUtil.success(dailySentence.getSentence());
    }
}
